#include "ShareMemory.hpp"
#include <pthread.h>
int main()
{
    Shm.GetShm();
    Shm.ShmAt();

    sleep(12);
    pthread_t * d = (pthread_t*)Shm.GetAddr();
    std::cout << "我接受了一个指针: " << d << std::endl;
    std::cout << "地址： " << ToHex(*d) << std::endl;
    void* ret;
    pthread_join(*d,&ret); //看来这个线程的地址是进程独有的!! 

    while(true){
        std::cout << "我从另一个进程的线程中获取的资源, ret: " << (long long)ret << std::endl;
        sleep(1);
    }
    // gpipe.OpenForWrite();

    // struct data* d= ( struct data*)Shm.GetAddr();

    // while(true){
    //     sleep(1); 
    //     strcpy(d->status,"最新");
    //     strcpy(d->lastime,GetCurime().c_str());
    //     strcpy(d->text,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    //     // sleep(3);
    //     gpipe.Signal();
    // }

    // char* strinfo = (char*)Shm.GetAddr();
    // char ch = 'A';
    // while(ch <= 'Z')
    // {
    //     strinfo[ch-'A'] = ch;
    //     ch++;
    //     sleep(3);
    // }
    Shm.ShmDt();
    return 0;
}